package net.cityside.jlearn.performance;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import net.cityside.jlearn.performance.MockBigData.BigObj;

public class OutOfMemoryMockPane extends JPanel {

	private static final long serialVersionUID = 1L;

	public OutOfMemoryMockPane() {
		JButton bigHeapBt = new JButton("Big Heap");
		add(bigHeapBt);
		bigHeapBt.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				BigObj[] bos = MockBigData.generateBigObject(500);
				try {
					Thread.sleep(100000);
				} catch (InterruptedException e1) {
				}
			}
		});

		JButton manyThreadBt = new JButton("Many Threads");
		add(manyThreadBt);
		manyThreadBt.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				BigObj[] bos = MockBigData.generateBigObject(1);
				Thread[] ts = MockBigData.generateManyThreads(10000);
				try {
					Thread.sleep(100000);
				} catch (InterruptedException e1) {
				}
			}
		});
	}

}
